<template>
  <a-layout id="components-layout-demo-custom-trigger">
    <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
      <div class="logo">欢迎你，{{ username }}</div>


    <leftmenu :menu_number="2"></leftmenu>

    </a-layout-sider>
    <a-layout>
      <headmenu></headmenu>
      <a-layout-content
        :style="{
          margin: '24px 16px',
          padding: '24px',
          background: '#fff',
          minHeight: '500px',
        }"
      >
      <a-breadcrumb>
    <a-breadcrumb-item>工单类型</a-breadcrumb-item>
    <!-- <a-breadcrumb-item><a href="">Application Center</a></a-breadcrumb-item> -->
    <!-- <a-breadcrumb-item><a href="">Application List</a></a-breadcrumb-item> -->
    <a-breadcrumb-item>工单类型</a-breadcrumb-item>
  </a-breadcrumb>
        <a-table bordered :data-source="dataSource" :columns="columns">
          <template slot="operation" slot-scope="text, record">
            <a-popconfirm title="是否删除" @confirm="() => work_del(record.id)">
              <a href="Javascript:void(0)">删除</a>
            </a-popconfirm>
            <a-popconfirm
              title="是否修改"
              @confirm="() => work_update(record.id)"
            >
              <a href="Javascript:void(0)">修改</a>
            </a-popconfirm>

            <a-popconfirm
              title="是否添加"
              @confirm="() => work_add(record.id)"
            >
              <a href="Javascript:void(0)">添加</a>
            </a-popconfirm>
          </template>
        </a-table>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script>
import { delete_work } from "./axios_http/api";
import leftmenu from './leftmenu.vue';
import headmenu from './headmenu.vue';
import { get_work } from "./axios_http/api";
export default {
  data() {
    return {
      collapsed: false,
      username: localStorage.getItem("username"),
      columns: [
        { title: "id", dataIndex: "id" },
        { title: "name", dataIndex: "name" },
        // 指定操作列
        {
          title: "operation",
          dataIndex: "operation",
          scopedSlots: { customRender: "operation" },
        },
      ],
      // 具体数据
      dataSource: [],
      work_list: [],
    };
  },
  components:{
    'leftmenu': leftmenu,
       headmenu:headmenu,
  },
  methods: {
    work_add(wid){
      this.$router.push({path:'/addwork/', query:{'wid': wid}})
    },
    work_del(wid) {
      delete_work({ data: { wid: wid } }).then((resp) => {
        console.log(resp);
        this.$message.info(resp.data);
      });
    },
    work_update(wid) {
      console.log(wid);
      this.$router.push({ path: "/updatework", query: { wid: wid } });
    },
    delete_userinfo() {
      localStorage.clear();
      this.$router.push("/login");
    },
  },
  created() {
    get_work().then((resp) => {
      console.log(resp);
      if (resp.code == 200) {
        console.log(resp)
        this.dataSource = resp.data;
      }
    });
  },
};
</script>


<style scoped>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
}
</style>